<html>
<script src="../../resources/js-test.js"></script>
<body style="min-height: 5000px"> 
<span id="elt">text</span>

<script>
description('Checks that bounds are handled properly when activating TextMatch markers.');

if (window.testRunner)
    testRunner.dumpAsText();

var range = document.createRange();
var elt = document.getElementById('elt').firstChild;
range.setStart(elt, 1);
range.setEnd(elt, 3);

if (!window.internals) {
    alert('This test requires window.interals to run!');
} else {
    internals.addTextMatchMarker(range, 'kInactive');

    internals.setTextMatchMarkersActive(elt, 0, 1, true);
    shouldBe('internals.activeMarkerCountForNode(elt)', '0');

    internals.setTextMatchMarkersActive(elt, 1, 2, true);
    shouldBe('internals.activeMarkerCountForNode(elt)', '1');

    internals.setTextMatchMarkersActive(elt, 2, 3, false);
    shouldBe('internals.activeMarkerCountForNode(elt)', '0');

    internals.setTextMatchMarkersActive(elt, 3, 4, true);
    shouldBe('internals.activeMarkerCountForNode(elt)', '0');
}

var successfullyParsed = true;
</script>
</body>
</html>
